<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        function setCookie(name,value,iDay){//设置cookie的名字、值、截止时间
            var oDate=new Date();
            oDate.setDate(oDate.getDate()+iDay);
           document.cookie=name+'='+value+';expires='+oDate;//给cookie添加内容

        }
        setCookie('userName','xiongcheng',100);
        setCookie('password','123456',100);
        alert(document.cookie);
    </script>
</head>
<body>

</body>
</html>